<?php
/**
 *   File functions:
 *   Game staff list
 *
 *   @name                 : stafflist.php                            
 *   @copyright            : (C) 2006 Vallheru Team based on Gamers-Fusion ver 2.5
 *   @author               : thindil <thindil@users.sourceforge.net>
 *   @version              : 1.2
 *   @since                : 15.07.2006
 *
 */

//
//
//       This program is free software; you can redistribute it and/or modify
//   it under the terms of the GNU General Public License as published by
//   the Free Software Foundation; either version 2 of the License, or
//   (at your option) any later version.
//
//   This program is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program; if not, write to the Free Software
//   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// $Id: stafflist.php 483 2006-07-15 08:30:20Z thindil $

$title = "Spis książąt";
require_once("includes/head.php"); if (!$_GET['ajax']) require_once("includes/head_start.php"); 

$smarty->caching = 2; // lifetime is per cache
$smarty -> cache_dir = 'cache';
$smarty->cache_lifetime = 3600;

if($smarty->is_cached('stafflist.tpl')) {
$smarty->display('stafflist.tpl');
} else {
/**
* Get the localization for game
*/
require_once("languages/".$player -> lang."/stafflist.php");

if ($player -> location != 'Altara' && $player -> location != 'Ardulith' && $player -> location != 'Port') 
{
    error (ERROR);
}

$arrStafflist = array(array(array(),
                            array()),
                      array(array(),
                            array()),
                      array(array(),
                            array()),
                      array(array(),
                            array()),
                      array(array(),
                            array()),
                      array(array(),
                            array()),
                      array(array(),
                            array()),
                      array(array(),
                            array()),
                      array(array(),
                            array()),
                      array(array(),
                            array()),
                      array(array(),
                            array()));
$arrKey = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
$arrNames = array('Admin', 'MG', 'Karczmarka', 'Skryba', 'Kapitan Gwardii', 'Gwardzista', 'Redaktor', 'Rycerz', 'Dama', 'Namiestnik', 'Radny'); 
$objStafflist = $db -> Execute("SELECT `id`, `user`, `rank` FROM `players` WHERE `rank`='Admin' OR `rank`='Namiestnik' OR `rank`='MG' OR `rank`='Radny' OR `rank`='Karczmarka' OR `rank`='Skryba' OR `rank`='Kapitan Gwardii' OR `rank`='Gwardzista' OR `rank`='Redaktor' OR `rank`='Rycerz' OR `rank`='Dama'") or die("Błąd!");
while (!$objStafflist -> EOF)
{
    $intKey = array_search($objStafflist -> fields['rank'], $arrNames);
    $intKey2 = $arrKey[$intKey];
    $arrStafflist[$intKey][0][$intKey2] = $objStafflist -> fields['id'];
    $arrStafflist[$intKey][1][$intKey2] = $objStafflist -> fields['user'];
    $arrKey[$intKey] = $intKey2 + 1;
    $objStafflist -> MoveNext();
}
$objStafflist -> Close();
$arrSecnames = array(SEC_NAME1, SEC_NAME2, SEC_NAME3, SEC_NAME4, SEC_NAME5);
$arrRanks = array(KINGS, 'Mistrzowie Gry', INNKEEP, LIBRARIANS, M_COUNT, COUNT, REDACTOR, KNIGHTS, LADIES, 'Namiestnicy', 'Radni');


$funkcje = $db -> Execute("SELECT id, user, funkcja FROM players WHERE funkcja != ''");
$arrid = array();
$arrname = array();
$arrfunkcja = array();
$i = 0;
while (!$funkcje -> EOF) 
{
	$arrid[$i] = $funkcje -> fields['id'];
	$arrname[$i] = $funkcje -> fields['user'];
	$arrfunkcja[$i] = $funkcje -> fields['funkcja'];
	$funkcje -> MoveNext();
	$i++;
}
$funkcje -> Close();


$fabularne = $db -> Execute("SELECT id, user, funkcjaFab FROM players WHERE funkcjaFab != ''");
$arridf = array();
$arrnamef = array();
$arrfunkcjaf = array();
$i = 0;
while (!$fabularne -> EOF) 
{
	$arridf[$i] = $fabularne -> fields['id'];
	$arrnamef[$i] = $fabularne -> fields['user'];
	$arrfunkcjaf[$i] = $fabularne -> fields['funkcjaFab'];
	$fabularne -> MoveNext();
	$i++;
}
$fabularne -> Close();



/**
* Assign variables to template and display page
*/
$smarty -> assign(array("Listinfo" => LIST_INFO,
                        "Secnames" => $arrSecnames,
                        "Stafflist" => $arrStafflist,
                        "Ranknames" => $arrRanks,
                        "Sec3desc" => SEC3_DESC,
                        "FunkcjeId" => $arrid,
                        "FunkcjeName" => $arrname,
                        "FunkcjeFunkcja" => $arrfunkcja,
                        "FabularneId" => $arridf,
                        "FabularneName" => $arrnamef,
                        "FabularneFunkcja" => $arrfunkcjaf,
                        "Sec3desc2" => SEC3_DESC2,
                        "Pllocation" => $player -> location));
$smarty -> display ('stafflist.tpl');
}

if (!$_GET['ajax']) require_once("includes/foot.php");
?>
